package diona;

import com.melloware.jintellitype.JIntellitype;
import diona.dao.SharedFileDao;

import java.awt.*;

/**
 * User: anton
 * Date: 13.03.11 20:40
 */
public class HotKeyListenerFactory
{
    private final SharedFileDao fileDao;

    public HotKeyListenerFactory(SharedFileDao fileDao)
    {
        this.fileDao = fileDao;
    }

    public void initHotKeysListeners(TrayIcon trayIcon)
    {
        Notifier notifier = new Notifier(trayIcon);
        registerListener(new ShareHotKeyListener(notifier, fileDao), JIntellitype.MOD_WIN, (int) 'V');
        registerListener(new QueueHotKeyListener(notifier, fileDao), JIntellitype.MOD_WIN, (int) 'C');
    }

    private void registerListener(HotKeyListener listener, int modifier, int keycode)
    {
        JIntellitype.getInstance().registerHotKey(listener.getEventType().code, modifier, keycode);
        JIntellitype.getInstance().addHotKeyListener(listener);
    }
}
